package com.meituan.meituanservice.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ResourceLoader;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
@RequestMapping("static")
public class ImagesController {
    @Autowired
    ResourceLoader resourceLoader;
    String path = "G:\\meituanUpload\\userAvatar";
    @GetMapping("avatar")
    public ResponseEntity show(String filename){
        try {
            return ResponseEntity.ok(resourceLoader.getResource( "file:"+ path + "/" + filename));
        } catch (Exception e) {
            return ResponseEntity.notFound().build();
        }
    }
}
